package com.shr.code_interview;

import java.util.ArrayList;
import java.util.List;

public class Solution_62 {
    public int LastRemaining_Solution(int n, int m) {
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i<n;i++)
        	list.add(i) ;
        int k = 0;
        while(list.size() != 1){
        	k = (k + m - 1) % list.size();
        	list.remove(k);
        }
        return list.get(0) ;
    }
}
